package top.soulblack.purchasesale.service;


import org.springframework.stereotype.Service;
import top.soulblack.purchasesale.mapper.GoodsSizeMapper;
import top.soulblack.purchasesale.model.GoodsColor;
import top.soulblack.purchasesale.model.GoodsSize;

import javax.annotation.Resource;
import java.util.List;

/**
 * create by 小川
 */

@Service
public class GoodsSizeService {

    @Resource
    private GoodsSizeMapper goodsSizeMapper;

    public List<GoodsSize> selectAll() {
        return goodsSizeMapper.selectAll();
    }

    public List<String> selectGroups() {
        return goodsSizeMapper.selectGroups();
    }

    public void addSize(GoodsSize goodsSize) {
        goodsSizeMapper.addSize(goodsSize);
        return;
    }

    public boolean existSize(String name) {
        int num  = goodsSizeMapper.existSize(name);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean deleteSize(int sizeId) {
        int num = goodsSizeMapper.deleteById(sizeId);
        if (num == 1) {
            return true;
        }
        return false;
    }
    public List<GoodsSize> selectForName(String sizeName) {
        return goodsSizeMapper.selectForName(sizeName);
    }

    public List<GoodsSize> selectForGroup(String group) {
        return goodsSizeMapper.selectForGroup(group);
    }

    public boolean updateSize(GoodsSize goodsSize) {
        int num = goodsSizeMapper.updateByPrimaryKey(goodsSize);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public String selectById(Integer id){
        return goodsSizeMapper.selectById(id);
    }

    public boolean selectSize(Integer sizeId){
        List<Integer> num = goodsSizeMapper.selectSize(sizeId);
        if (num  != null) {
            return true;
        }
        return false;
    }
}
